<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.min.css" />
    <script type="text/javascript" src="./script/jquery.min.js"></script>
</head>

<body>
    <header class="aui-bar aui-bar-nav header">
        <a class="aui-pull-left">
        </a>
        <div class="aui-title" id='title'>条件</div>
        <a class="aui-pull-right aui-btn">
            <!-- <span class="fa fa-user-circle-o"></span> -->
        </a>
    </header>
    <div class="header-d"></div>
    <div class="list-t">
        <img src="images/cover_logo.png">
        <span>领导干部电子点名手册</span>
    </div>
    <!-- 条件 -->
    <div class="search">
        <ul>
            <li>
                <p>姓名：</p>
                <input class="text-1" type="text" name="name">
            </li>
            <li>
                <p>年龄：</p>
                <input class="text-2" type="text" name='symbol' placeholder="'>' 或  '<'">
                <span>-</span>
                <input class="text-2" type="text" name='age' placeholder="年龄">
            </li>
            <li>
                <p>性别：</p>
                <div class="aui-list-item-input" name='sex'>
                    <label><input class="aui-radio" type="radio" value='男' name="sex" checked>男</label>
                    <label><input class="aui-radio" type="radio" value='女' name="sex">女</label>
                </div>
            </li>
        </ul>
        <div class="search-btn">
            <button type="button" onclick="search()">搜索</button>
        </div>
    </div>
</body>

</html>
<script>
    function search() {
        var name = $('input[name="name"]').val();
        sql = 'SELECT * FROM base_info WHERE ';
        if (name != '') {
            name = "'" + name + "'";
            nameSql = 'name=' + name + ' AND';
            sql = sql + nameSql;
        }
        //年龄
        var symbol = $('input[name="symbol"]').val();
        var age = $('input[name="age"]').val();
        if (symbol != '' && age != '') {
            var date = getcurrent(age);
            date = "'" + date + "'";
            sql = sql + date + ' ' + symbol + ' I03 AND';
        }

        //性别
        var sex = $('input:radio[name="sex"]:checked').val();
        sex = "'" + sex + "'";
        sql = sql + ' base_info.I02 = ' + sex;

        api.openWin({
            name: 'classify_4',
            url: './classify_4.html',
            pageParam: {
                sql: sql,
                type: '1'
            }
        });
    }

    apiready = function() {




    }

    function getcurrent(age) {
        //将一个月的日期填入搜索框
        var currentYear = new Date().getFullYear() - age;
        var currentMonth = new Date().getMonth() + 1;
        var currentDate = new Date().getDate();
        var current = currentYear + "-" + currentMonth + "-" + p(currentDate);
        return current;
    }

    function p(s) {
        return s < 10 ? '0' + s : s;
    }
</script>
